pp108 : Format Type

Format Type

 


A Format Type represents a JavaScript object that contains attributes to define the formatting and validation applicable to a control. This object enables run-time formatting and validation for a control and can be attached to any control. When attached to a control, its value is set according to the attributes available in the object.
This object must be retrieved using the getFormatType() method available on the control.

Note: In case of data-bound controls, the Format Type object is available as an event object property for the xforms-before-data-bind event. For the Select control, it is available on the xforms-select-before-data-fill event. A number of methods are available for use with the Format Type object. When you use a set() method available for the object, you must also set the Format Type on the control. This ensures that the changes specified through the method are affected and can be retrieved using the get() method. The Format Type can be set on a control using the following format,

control.setFormatType(oFormatType)


The following methods are available for Format Type object.

Table 1. List of Methods

Method

Description

Data Type to Which Applicable

format(sData)

This method returns the formatted value of the data based on the format type.

Integer, Float, Double, Decimal, Amount, String, Date

getDataAlignment()

This method returns the alignment of data in a control. Possible values are "left", "center", and "right".

Integer, Float, Double, Decimal, Amount, String, Date, Hex Binary, Base64Binary, Any URI

getDataType()

This method returns the data type specified for a control.

Integer, Float, Double, Decimal, Amount, String, Date, Hex Binary, Base64Binary, Any URI

getDecimalPlaces()

This method returns the number of decimal places to allow in a control.

Float, Double, Decimal, Amount

getDisplayFormat(bStringFormat)

This method returns the display format of the object. Refer to Predefined and Specific Formats for Data Types for more information on the display formats available in Process Platform. 
A parameter(optional) is applicable only for objects of the Date type. The possible values are:

  • "true": Returns date in a string format
  • "false": Returns date in a predefined format
    .

Integer, Float, Double, Decimal, Amount, String, Date

getIllegalCharacterSet()

This method returns the characters that cannot be used in a control.

String

getLegalCharacterSet()

This method returns the characters that can be used in a control.

String

getLocale()

This method returns the locale.

Integer, Float, Double, Decimal, Amount, Date

getMaxInclusive()

This method returns the maximum value allowed in a control.

Integer, Float, Double, Decimal, Amount

getMaxLength()

This method returns the maximum length allowed in a control.

String

getMinInclusive()

This method returns the minimum value allowed in a control.

Integer, Float, Double, Decimal, Amount

getMinLength()

This method returns the minimum length allowed in a control.

String

getNegativePattern()

This method returns the display format for negative values in a control.

Integer, Float, Double, Decimal, Amount

getPositivePattern()

This method returns the display format for positive values in a control.

Amount

getRequired()

This method returnstrueif a control is set as mandatory.

Integer, Float, Double, Decimal, Amount, String, Date, Hex Binary, Base64Binary, Any URI

getTimezone()

This method returns the time zone.
Note: If there is no time zone set in User Preferences, 'client', which is the system time zone, will be returned by default.

Date

setCurrency(sCurency)

This method sets the currency. For information about the currencies supported in Process Platform and their codes, see Currencies.
Note: If used, the value set using the setCurrency() method overwrites the value set using the setLocale() method.

Amount

setDataAlignment(sDataAlignment)

This method sets the alignment of data in a control. Possible values are:

  • "left": aligns data to the left-hand side of the control.
  • "center": aligns data to the center of the control.
  • "right": aligns data to the right-hand side of the control.

Integer, Float, Double, Decimal, Amount, String, Date, Hex Binary, Base64Binary, Any URI

setDataType(sDataType)

This method set the data type to be associated with the control. Possible values areinteger, float, decimal, double, date, amount, string, hexbinary, base64binaryandanyuri.

Integer, Float, Double, Decimal, Amount, String, Date, Hex Binary, Base64Binary, Any URI

setDecimalPlaces()

This method sets the number of decimal places to allow in a control. You need to specify an integer value.

Float, Double, Decimal, Amount

setDisplayFormat()

This method sets the display format of the object. It overwrites any earlier format set programmatically. For information about the display formats available in Process Platform, see Predefined and Specific Formats for Data Types.

Integer, Float, Double, Decimal, Amount, String, Date

setIllegalCharacterSet()

This method sets the characters that cannot be used in a control.

String

setLegalCharacterSet()

This method sets the characters that can be used in a control.

String

setLocale()

This method sets the locale; information such as language, country, and currency is set accordingly. For information about the locales supported in Process Platform and their codes, see Locales.

Integer, Float, Double, Decimal, Amount, Date

setMaxInclusive()

This method sets the maximum value allowed in a control. You must specify a value corresponding to the selected datatype.

Integer, Float, Double, Decimal, Amount

setMaxLength()

This method sets the maximum length allowed in a control. You need to specify an integer value.

String

setMinInclusive()

This method sets minimum value allowed in a control. You must specify a value corresponding to the selected datatype.

Integer, Float, Double, Decimal, Amount

setMinLength()

This method sets the minimum length allowed in a control. You need to specify an integer value.

String

setNegativePattern()

This method sets the display format for negative values in a control. You can specify values in the Amount, Integer, Float, Double, and Decimal datatypes.

  • Possible values for the Amount datatype are '($n)', '$n', '$-n', '$â€"', '(n$), '-n$', 'â€"$', 'n$', '($ n)', '$ n', '$ -n', '$ â€"', '(n $)', '-n $', 'â€" $', 'n $'.
  • Possible values for the Integer, Float, Double, and Decimal datatypes are '- n', 'â€"', 'n -'.

Integer, Float, Double, Decimal, Amount

setPositivePattern()

This method sets the display format for positive values in a control.Possible values are '$n', '$ n', 'n$', 'n $'.

Amount

setRequired()

This method sets a control as mandatory. You need to specify a boolean value. Possible values aretrueandfalse.

Integer, Float, Double, Decimal, Amount, String, Date, Hex Binary, Base64Binary, Any URI

setTimezone()

This method sets the time zone. For information about the time zones supported in Process Platform, see Time Zones.

Date

 

Example


The following example demonstrates the use of the Format Type object.

// get the formatType object for employee age field. var ft = emp_age.getFormatType(); // Set max inclusive as 58 ft.setMaxInclusive(58); emp_age.setFormatType(ft); // display the new max inclusive value for employee age field var maxInclusiveValue = emp_age.getFormatType().getMaxInclusive(); application.notify("Max Inclusive value - " + maxInclusiveValue);

Related reference

getFormatType()
setFormatType()
WebForm.getFormatType()